Description:
NavigationController搭配TabBarController常出現在各類型的App中。
此demo功能如下:
Component:
Highlight function:
let tabbarcntrl = UITabBarController()
tabbarcntrl.viewControllers = [nvHome, dashboardVC, notifyVC]
let tabHome = tabbarcntrl.tabBar.items![0]
let tabDashboard = tabbarcntrl.tabBar.items![1]
let tabNotify = tabbarcntrl.tabBar.items![2]
let nvHome = UINavigationController(rootViewController: homeVC)
navigationController!.pushViewController(SomeViewController, animated: true)
Additional:
UITabBarController是以array的方式來儲存,最多可以放五個圖示,超過的話最右邊的會變成一個More的圖示,按下後會列出來後續可前往的頁面。
TabBarController可以透過本身的member variable來指定起始頁面為哪個畫面:
TabBar.selectedIndex = 0
Reference:
Source code on Github